package com.itheima.search.controller;

import com.hmall.common.dto.PageDTO;
import com.itheima.search.domain.RequestParams;
import com.itheima.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    SearchService searchService;


    @GetMapping("/sync")
    public void importes(){
        searchService.importes();

    }
    @PostMapping("/filters")
    public Map filters(@RequestBody RequestParams params){
        Map<String, List<String>> map=searchService.filters(params);
        return  map;
    }


    @PostMapping("/list")
    public  PageDTO list(@RequestBody RequestParams requestParams){
        return  searchService.search(requestParams);
    }




}
